<?php

namespace Auth\Controller;

use Application\Controller\AbstractController;
use Zend\View\Model\ViewModel;
use Auth\Form\ChangePasswordForm;
use Zend\Json\Json;
use Zend\Crypt\Password\Bcrypt;
//use HVTC\HVTC;
use Auth\Form\ProfileForm;
use Auth\Model\Users;
//use Facebook\Model\FacebookUser;
use Zend\Validator\File\MimeType;
use Zend\Filter\File\Rename;
use Zend\Session\Container;
use Zend\Paginator\Paginator;
use Zend\Paginator\Adapter\ArrayAdapter;
use Zend\Db\Sql\Select;


class ProfileController extends AbstractController{
	
	public function profileAction(){
	    
		return new ViewModel();
	}
	private function gotoProfile(){
		
	}
	public function reloadAvatarAction(){
		
	}
	
	private function updateSocialInfo($userData){
		
	}
	public function upgradeAction(){
		
	}
	public function updateProfileAction(){
		
	}

	public function changePassAction(){
	    $request = $this->getRequest();
	    $email=$this->getAuthSession('email');
	    $password_new = $request->getPost('new_password');
	    $password_confirm = $request->getPost('confirm-password');
	    $user = $this->getUserMapper()->getUserByEmail($email);
	    
	    if($user->getId()){
	        $bcrypt        = new Bcrypt();
	        $new_hash      = $bcrypt->setSalt($user->getPasswordSalt())->create($request->getPost('current-password')) ;
	        $authAdapter   = $this->getAuthService()->getAdapter();
	        $authAdapter->setCredential($new_hash)->setIdentity($user->getEmail());
	        $result        = $authAdapter->authenticate();
	        
	        
	    }
	      
	}
	
	private function loginUser($userId){
		
	}
}